import axios from 'axios';

/**
 * axios配置工具
 */
//1.创建axios对象
const service = axios.create({
  baseURL: 'http://192.168.91.236:3000',
});

//2.请求拦截
service.interceptors.request.use(
  config => {
    return config;
  },
  error => {
    Promise.reject(error);
  },
);

//3.响应拦截
service.interceptors.response.use(
  response => {
    //判断code码
    // if (response.data.code === 40001) {
    //   window.location.replace('/');
    // }
    return response.data;
  },
  error => {
    return Promise.reject(error);
  },
);

export default service;
